home *** CD-ROM | disk | FTP | other *** search
/ Network Support Library / RoseWare - Network Support Library.iso / apidev / ndr3.exe / VERVLM.C < prev    next >
C/C++ Source or Header  |  1993-11-04  |  2KB  |  95 lines

  1. /*
  2.    VERVLM.C  shows how to obtain the version numbers
  3.              of VLM.EXE and any VLM loaded by it.
  4.  
  5.    Author:  Tim Farley
  6.    Copyright 1993, Tim Farley, All Rights Reserved
  7. */
  8.  
  9. #include <stdlib.h>  /* for NULL */
  10. #include <dos.h>     /* for _dos_getvect() or getvect() */
  11.  
  12. #ifdef __TURBOC__
  13.    #define ASM asm
  14.    #define GETVECT getvect
  15. #else
  16.    /* assume Microsoft C if not Turbo/Borland C */
  17.    #define ASM _asm
  18.    #define GETVECT _dos_getvect
  19. #endif
  20.  
  21. /*
  22.    Pointer to the VLM entry point
  23. */
  24. static void (far * VLMentry)(void) = NULL;
  25.  
  26.  
  27. /*
  28.    DetectVLM  detects if the NetWare DOS Requestor
  29.               is present & retreives its entry point.
  30. */
  31. static int DetectVLM( void )
  32. {
  33.    unsigned long int2Fvector;
  34.    int returnCode;
  35.  
  36.    /* if we've already been called, skip it */
  37.    if  ( NULL != VLMentry )
  38.       return ( 1 );
  39.  
  40.    /*
  41.       Make sure INT 2Fh is initialized.  This is only
  42.       technically necessary to support DOS 2.x.
  43.    */
  44.    int2Fvector = (unsigned long)GETVECT( 0x2F );
  45.    if  ( 0UL == int2Fvector )    /* No INT 2Fh handler? */
  46.       return ( 0 );              /* then no IPX!  */
  47.  
  48.    ASM {
  49.       xor   bx,bx       /* clear return registers */
  50.       mov   es,bx
  51.       mov   ax,7a20h    /* FN 7A00: Detect IPX */
  52.       xor   bx,bx       /* BX = 0 returns main entry point */
  53.       int   2fh
  54.       mov   returnCode,ax                 /* save return code */
  55.       mov   word ptr VLMentry,bx          /* store API entry */
  56.       mov   word ptr VLMentry+2,es
  57.    }
  58.  
  59.    return ( 0 == returnCode );   /* AX = 0 means success */
  60. }  /* DetectVLM() */
  61.  
  62.  
  63. /*
  64.    GetVLMVersion  returns the version of a given VLM by
  65.                   number.  Use #1 for VLM.EXE.  Returns 0
  66.                   if not loaded.
  67. */
  68. int GetVLMVersion( int whichVLM )
  69. {
  70.    int returnCode, vlmHigh, vlmLow;
  71.  
  72.    if  ( !DetectVLM() )
  73.       return( 0 );
  74.  
  75.    ASM {
  76.       xor   ax,ax       /* Source VLM = 0 (we are an app) */
  77.       push  ax
  78.       push  whichVLM    /* Target VLM */
  79.       mov   ax,1
  80.       push  ax          /* Target Func: VLM_NOTIFY */
  81.       mov   bx,0        /* Subfunction: NOTIFY_VER */
  82.       call  VLMentry
  83.       mov   returnCode,ax
  84.       mov   vlmHigh,bx
  85.       mov   vlmLow,cx
  86.    }
  87.  
  88.    if  ( 0 != returnCode )
  89.       return ( 0 );
  90.  
  91.    return ( ( vlmHigh << 8 ) | vlmLow );
  92. }  /* GetVLMVersion() */
  93.  
  94.  
  95. /* eof: VERVLM.C */